// pages/accordion/accordion.js

let app = getApp();
import util from '../../../utils/util.js';

Page({
  data: {
    orderinfo:'',
    imagelist:[],
    repairlist:[],
  },
  

  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: "详情"
    });


    
    let data = JSON.parse(options.data);
    this.getrepair(data.repairid);
    console.log(data);
    var list_pic = [];
    // if (data.iscommented ==1)
    // {
    var pics = data.pics;
    var list = pics.split(",");
    
    for(var url in list)
    {
      url = "https://www.autorepairehelper.cn/file/pic/" + list[url]+".png";
      
      list_pic.push(url);
    }
    // } else {

    // }
    this.setData({
      orderinfo: data,
      imagelist: list_pic,
    });
    
  },

  formSubmit(event) {
    let data = JSON.stringify(this.data.orderinfo);

    wx.navigateTo({
      url: '../addcomment/addcomment?data=' + data,
    });
  },

  delSubmit(event){
    var url = app.globalData.SERVER + 'repair/queryAllWithStateByCarer';

    // var usetinfo = wx.getStorageSync("user_info");
    var usetinfo = util.getData("userinfo");


    var usetinfo_id = usetinfo._id;
    var tel = usetinfo.tel;
    var time = '2018-08-24 00:00:00';

    var status = this.data.type;
    util.request(url, 'POST', {
      owner: tel,
      insertTime: time,
      state: status,
      page: '0',
      pagesize: '30',
      carerid: usetinfo_id,
    }).then(res => {
      util.showToast('成功', 'error', 2500);
    }).catch(err => {
      if (err.data.code === 1) {
        console.log(err.data.ret);
        this.setData({
          infolist: err.data.ret,
        });
        var num = 1;
      } else {
        self.setData({
          siteInfo: err.data.site_info
        });
      }


    });
  },
  getrepair(repairid) {
    var url = app.globalData.SERVER + 'repair/queryOne';

    var showinfo = [];
    util.request(url, 'POST', {
      id: repairid,
    }).then(res => {
      util.showToast('成功', 'error', 2500);
    }).catch(err => {
      if (err.data.code === 1) {
        console.log(err.data.ret);
        var showinfo = err.data.ret.items;
        this.setData({
          repairlist: showinfo,
          // piclist:strarytmp,
        });
        var num = 1;
      } else {

      }


    });
  }
})